-
-
Notifications
You must be signed in to change notification settings - Fork 684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📝 Add docs page for self-referential model #408
base: main
Are you sure you want to change the base?
Conversation
📝 Docs preview for commit e3dd424 at: https://6308770b7b8d7658d78c68dc--sqlmodel.netlify.app |
📝 Docs preview for commit 1860515 at: https://630879743f533d5c007b1ebc--sqlmodel.netlify.app |
Codecov Report
@@ Coverage Diff @@
## main #408 +/- ##
==========================================
- Coverage 97.76% 96.99% -0.78%
==========================================
Files 187 188 +1
Lines 6268 6318 +50
==========================================
Hits 6128 6128
- Misses 140 190 +50
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
📝 Docs preview for commit 51d7d80 at: https://6311b4a3b6b5535c3dfe9f74--sqlmodel.netlify.app |
📝 Docs preview for commit 6e10a41 at: https://6311b96eef8da65cd180f3e6--sqlmodel.netlify.app |
📝 Docs preview for commit 5b4c9e4 at: https://6311ba9503310f5f48cdd4f0--sqlmodel.netlify.app |
📝 Docs preview for commit c702e78 at: https://639ce0eaa12b8e030c9de393--sqlmodel.netlify.app |
@tiangolo, what's blocking this from being merged? |
Purpose
Adds a new page explaining how to construct a self-referential/recursive relationship with SQLModel to the Advanced User Guide section of the documentation. This is arguably a fairly common use case that has been asked about and discussed in issue #127 already.
Code
The example code uses a
Villain
class/model for demonstration in an attempt at honoring theHero
theme of the documentation. A villain can have aboss
villain and villainminions
.Additional info
The new page also includes a brief explanation of the
sa_relationship_kwargs
parameter of theRelationship
constructor, since that is essential for defining the desired relationship. Depending on how @tiangolo wants to structure the rest of the advanced guide, this section may either need to be expanded or instead abbreviated to a short mention and link to a dedicated section forsa_
-style parameters in SQLModel fields and relationships in the future.Update (2022-08-02)
Rebased onto most recent version of the
main
branch (0.0.8 release, 75ce455).Then rebased again, after adding tests to cover the new documentation example code. Coverage of the added code should now be at 100% (see latest codecov checks).